package www.rlicker.service.impl;

import www.rlicker.model.Memberships;

import java.util.Map;

import javax.annotation.Resource;

import www.rlicker.dao.IMembershipsDao;

import org.springframework.stereotype.Service;

import www.rlicker.mybatis.Criteria;
import www.rlicker.service.IMembershipsService;
import www.rlicker.utils.MessageConstant;
import www.rlicker.utils.TranslateToMap;

import java.util.List;


@Service
public class MembershipsServiceImpl implements IMembershipsService{

	public List<Map<String, Object>>  queryPage (Criteria<Memberships> param){
		List<Memberships> list = membershipsRepository.queryPage(param);
			List<Map<String,Object>> map = TranslateToMap.convertListBean2ListMap(list,Memberships.class);
	return map;  }

	public Integer queryPageCount (Criteria<Memberships> param){
		return (Integer) membershipsRepository.queryPageCount(param);
	}

	public Memberships  queryEntity (String id ){
		return membershipsRepository.queryEntity(id);
	}

	public String deleteById (String id ){
		int result = membershipsRepository.deleteById(id);
			if ( result != 1) {
					return MessageConstant.USER_TYPE_3;
			}
			return null;
	}

	public String insert(Memberships record ){
		int result = membershipsRepository.insert(record);
			if ( result != 1) { 
					return MessageConstant.USER_TYPE_4;
			}
			return null;
	}

	public String update (Criteria<Memberships> param){
		int result = membershipsRepository.update(param);
			if ( result != 1) { 
					return MessageConstant.USER_TYPE_5;
			}
			return null;
	}
	
	@Override
	public String deleteAll() {
		int result =membershipsRepository.deleteAll();
		if ( result != 1) { 
			return MessageConstant.USER_TYPE_3;
		}
	  return null;
	}

	@Resource
	private IMembershipsDao membershipsRepository;

}